<extend name="Public/common"/>
<block name="body">
    <style>
        a {
            text-decoration: none;
            out-line: none;
            color: #000000;
        }
    </style>
    <!--   CREATE TABLE `agency_supplier_list` (
       `supplier_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '供应商id',
       `supplier_name` varchar(60) NOT NULL COMMENT '供应商名称',
       `company_name` varchar(60) NOT NULL COMMENT '公司名称',
       `company_phone` varchar(17) NOT NULL COMMENT '公司电话',
       `company_address` varchar(255) NOT NULL COMMENT '公司地址',
       `legal_name` varchar(50) NOT NULL COMMENT '法人姓名',
       `idcard_number` varchar(20) NOT NULL COMMENT '法人身份证号',
       `idcard_face` varchar(255) NOT NULL COMMENT '法人身份证正面',
       `idcard_back` varchar(255) NOT NULL COMMENT '法人身份证背面',
       `company_number` varchar(20) NOT NULL COMMENT '工商注册登记证号',
       `business_license` varchar(255) NOT NULL COMMENT '资质证书照片（营业执照）',
       `phone` varchar(17) NOT NULL COMMENT '联系人电话',
       `email` varchar(50) NOT NULL COMMENT '联系人邮箱',
       `qq_number` varchar(15) NOT NULL COMMENT '联系人QQ',
       `region_id` text NOT NULL COMMENT '所服务地区的id（json数据，存在可服务多地可能）',
       `deposit_bank` varchar(60) DEFAULT NULL COMMENT '开户行名称',
       `bank_account` varchar(30) DEFAULT NULL COMMENT '银行账户',
       `account_holder` varchar(60) DEFAULT NULL COMMENT '账户持有人姓名',
       `state` tinyint(4) NOT NULL DEFAULT '3' COMMENT '状态（1-审核通过，2-审核失败，3-审核中）',
       PRIMARY KEY (`supplier_id`)
       ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='供应商列表';-->
    <!--<form action="{:U('Attestation/upload')}" method="post" enctype="multipart/form-data">-->
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <div class="ibox-content">
                            <div class="form-horizontal">
                                <form action="{:U('Attestation/uploadPicture')}" enctype="multipart/form-data" method="post"
                                      id="fo">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">供应商名称</label>
                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" name="supplier_name"
                                                   placeholder="供应商名称"
                                                   id="supplier_name">
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">公司名称</label>

                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" name="company_name"
                                                   placeholder="公司名称"
                                                   id="company_name">
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">公司电话</label>

                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" name="company_phone"
                                                   placeholder="公司电话"
                                                   id="company_phone">
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">公司地址</label>

                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" name="company_address"
                                                   placeholder="公司地址" id="company_address">
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">法人姓名</label>

                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" name="legal_name" placeholder="法人姓名"
                                                   id="legal_name">
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">法人身份证号</label>

                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" name="idcard_number"
                                                   placeholder="法人身份证号" id="idcard_number">
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>


                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">法人身份证正面</label>
                                        <div class="col-sm-10">
                                            <!--dom结构部分-->
                                            <!--<input type='file'  name='photo1'>-->
                                            <input type="file" name="photo[]" value="法人身份证正面" id="send1">
                                        </div>
                                    </div>

                                    <div class="hr-line-dashed"></div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">法人身份证背面</label>
                                        <div class="col-sm-10">
                                            <input type='file' name='photo[]' id="send2">
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>


                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">工商注册登记证号</label>

                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" name="company_number"
                                                   placeholder="工商注册登记证号" id="company_number">
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">资质证书照片（营业执照）</label>

                                        <div class="col-sm-10">
                                            <input type='file' name='photo[]' id="send3">
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">联系人电话</label>

                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" name="phone" placeholder="联系人电话"
                                                   id="phone">
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">联系人邮箱</label>

                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" name="email" placeholder="联系人邮箱"
                                                   id="email">
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">联系人QQ</label>

                                        <div class="col-sm-10">
                                            <input type="number" class="form-control" name="qq_number" placeholder="联系人QQ"
                                                   id="qq_number">
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">所服务地区</label>

                                        <div class="col-sm-10">
                                            <select name="region_id" id="region_id" onchange="region_select()" id="point_one">
                                                <option value="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<--请选择--></option>
                                                <foreach name="list" item="v">
                                                    <option value="{$v.region_id}">{$v.region_name}</option>
                                                </foreach>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">开户行名称</label>

                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" name="deposit_bank"
                                                   placeholder="开户行名称"
                                                   id="deposit_bank">
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">银行账户</label>

                                        <div class="col-sm-10">
                                            <input type="number" class="form-control" name="bank_account"
                                                   placeholder="银行账户"
                                                   id="bank_account">
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">账户持有人姓名</label>

                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" name="account_holder"
                                                   placeholder="账户持有人姓名" id="account_holder">
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>

                                    <input type="hidden" class="form-control" name="state" id="state" value="2">

                                    <div class="form-group">
                                        <div class="col-sm-4 col-sm-offset-2">
                                            <button class="btn btn-primary" id="save">保存内容</button>
                                            <button class="btn btn-white" type="button" onclick="reset();">重置</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--</form>-->
    <script src="__JS__/http/upload.js"></script>
    <script type="text/javascript">
        function region_select() {
          var  a=$('#region_id').val()
            if(!(a==2 || a==3 || a==10 || a==23)){
              var b='';
                $.ajax({
                    url:"{:U('Attestation/region')}",
                    data:'id='+a,
                    type:'post',
                    dataType:'json',
                    success:function (e) {
                        for(var k in e){
                        b+='<option value='+e[k]['region_id']+'>'+e[k]['region_name']+'</option>'
                        }

                        $('#region_id').after('<select name=\'region_id\' id=\'region_id\'>\n' +
                            '<option value=\'\'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<--请选择--></option>'+b+'</select>');
                        $('#region_id').remove()
                    }
                })
            }
        }
        $('#save').click(function () {
            var supplier_name = $.trim($('#supplier_name').val())
            var company_name = $.trim($('#company_name').val())
            var company_phone = $.trim($('#company_phone').val())
            var company_address = $.trim($('#company_address').val())
            var legal_name = $.trim($('#legal_name').val())
            var idcard_number = $.trim($('#idcard_number').val())
            var company_number = $.trim($('#company_number').val())
            var phone = $.trim($('#phone').val())
            var email = $.trim($('#email').val())
            var qq_number = $.trim($('#qq_number').val())
            var region_id = $.trim($('#region_id').val())
            var deposit_bank = $.trim($('#deposit_bank').val())
            var bank_account = $.trim($('#bank_account').val())
            var account_holder = $.trim($('#account_holder').val())
            var state = $.trim($('#state').val())

            if (supplier_name == '') {
                layer.msg("供应商名称不能为空！");
                return false;
            }
            if (company_name == '') {
                layer.msg("公司名称不能为空！");
                return false;
            }
            if (company_phone == '') {
                layer.msg("公司电话不能为空！");
                return false;
            }
            if (company_address == '') {
                layer.msg("公司地址不能为空！");
                return false;
            }
            if (legal_name == '') {
                layer.msg("法人姓名不能为空！");
                return false;
            }
            if (company_number == '') {
                layer.msg("工商注册登记证号不能为空！");
                return false;
            }
            if (qq_number == '') {
                layer.msg("联系人QQ不能为空！");
                return false;
            }
            if (region_id == '') {
                layer.msg("所服务地区不能为空！");
                return false;
            }
            if (deposit_bank == '') {
                layer.msg("开户行名称不能为空！");
                return false;
            }
            if (bank_account == '') {
                layer.msg("银行账户不能为空！");
                return false;
            }
            if (account_holder == '') {
                layer.msg("账户持有人姓名不能为空！");
                return false;
            }
            if (idcard_number == '') {
                layer.msg("法人身份证号");
                return false;
            } else if (!(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(idcard_number))) {
                layer.msg("身份证格式不正确");
                return false;
            }
            if (phone == '') {
                layer.msg("请填写联系方式");
                return false;
            } else if (!(/^1\d{10}$/.test(phone))) {
                layer.msg("手机号码格式不正确");
                return false;
            }
            if (email == '') {
                layer.msg("请填写邮箱");
                return false;
            } else if (!(/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/).test(email)) {
                layer.msg("邮箱格式不正确");
                return false;
            }

            var file1 = document.getElementById("send1").value;
            if (file1.length < 1) {
                layer.msg("法人身份证正面");
                return false;
            }
            var file2 = document.getElementById("send2").value;
            if (file2.length < 1) {
                layer.msg("法人身份证背面");
                return false;
            }
            var file3 = document.getElementById("send3").value;
            if (file3.length < 1) {
                layer.msg("资质证书照片");
                return false;
            }
            if (supplier_name && company_name && company_phone && company_address && legal_name && idcard_number
                && company_number && phone && email && qq_number && region_id && deposit_bank && bank_account &&
                account_holder && state
            ) {
                $("#fo").submit()
            } else {
                alert('您有未填写的选项')
                return false;
            }
        })
    </script>
</block>